from flask import Flask
#导入三个蓝图
from apps.cms import bp as cmd_bp
from apps.common import bp as common_bp
from apps.front import bp as front_bp
import config
from exts import db, mail
from flask_wtf import CSRFProtect

def create_app():
    app = Flask(__name__)
    #配置文件
    app.config.from_object(config)

    #三个蓝图注册下
    app.register_blueprint(cmd_bp)
    app.register_blueprint(common_bp)
    app.register_blueprint(front_bp)

    db.init_app(app)
    #发邮件
    mail.init_app(app)
    #CSRF攻击
    CSRFProtect(app)

    return app

if __name__ == '__main__':
    app = create_app()
    app.run()
